package com.example.t1p3;

import java.util.LinkedList;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.EditText;

public class EndPeriodActivity extends Activity {
	
	private LinkedList<Goal> listGoal;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_end_period);
        
        listGoal = (LinkedList<Goal>) IntentHelper.getObjectForKey("listGoal");
		
		//populate the list with the list of goal
        EditText txt1 = (EditText)findViewById(R.id.editText1);
        String goalMsg = "";
        
        for (int i =0; i< listGoal.size();i++){
        	goalMsg += "TEAM: " + listGoal.get(i).getTeam().getNom() + "\n";
        	goalMsg += "GOAL: " + listGoal.get(i).getGoal().getLastName() + " " + Integer.toString(listGoal.get(i).getGoal().getNumber()) + "\n";
        	if (listGoal.get(i).getAssist1() != null)
        		goalMsg += "ASSIST: " + listGoal.get(i).getAssist1().getLastName() + " " + Integer.toString(listGoal.get(i).getAssist1().getNumber());
        	if (listGoal.get(i).getAssist2() != null)
        		goalMsg += ", " + listGoal.get(i).getAssist2().getLastName() + " " + Integer.toString(listGoal.get(i).getAssist2().getNumber()) + "\n";
        	goalMsg += "\n-------------------\n";
        }
        if(goalMsg.trim().length() == 0)
        	goalMsg = "No Goal This Period.\n-------------------\n";
        txt1.setText(goalMsg);
    }
    
    public void cancel(View view) {
    	Intent intent = new Intent();
        setResult(RESULT_CANCELED, intent);
        finish();
    }
    
    public void ok(View view) {    	
		int period = (Integer) IntentHelper.getObjectForKey("period");
		
		if(period == 3){			
			Intent intent = new Intent(this, ThreeStarsActivity.class);
	    	startActivity(intent);	
		}
		
        setResult(RESULT_OK, new Intent());
        finish();
    }
}
